/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.weatherEver.business.entity;

import java.io.Serializable;
import java.sql.Date;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.validation.constraints.Future;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Ettore
 */
@Entity (name="Event")
public class Event implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @NotNull
    private Boolean privacy;
    @NotNull
    private Boolean outdoor;
    @Size (max= 255)
    private String description;
    @Size (max= 255)
    private String title;
    @NotNull @Future (message="May not be null")
    private Date starting;
    @NotNull @Future (message="May not be null")
    private Date ending;
    @ManyToOne
    @JoinColumn (name="OWNER_ID")
    private User owner;
    @ManyToMany (mappedBy= "eventListToEnjoy")
    private List<User> invitedUser;
    @OneToMany (mappedBy="notifiedEvent")
    private List<Notification> generatedNotification;
    @OneToMany (mappedBy="referedEvent")
    private List<Invitation> generatedInvitation;
    private String place;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public User getOwner() {
        return owner;
    }

    public void setOwner(User owner) {
        this.owner = owner;
    }

    public List<User> getInvitedUser() {
        return invitedUser;
    }

    public void setInvitedUser(List<User> invitedUser) {
        this.invitedUser = invitedUser;
    }

    public List<Notification> getGeneratedNotification() {
        return generatedNotification;
    }

    public void setGeneratedNotification(List<Notification> generatedNotification) {
        this.generatedNotification = generatedNotification;
    }

    public List<Invitation> getGeneratedInvitation() {
        return generatedInvitation;
    }

    public void setGeneratedInvitation(List<Invitation> generatedInvitation) {
        this.generatedInvitation = generatedInvitation;
    }

    public String getPlace() {
        return place;
    }

    public void setPlace(String place) {
        this.place = place;
    }
    

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (getId() != null ? getId().hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Event)) {
            return false;
        }
        Event other = (Event) object;
        if ((this.getId() == null && other.getId() != null) || (this.getId() != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.polimi.weatherEver.business.entity.Event[ id=" + getId() + " ]";
    }

    /**
     * @return the privacy
     */
    public Boolean getPrivacy() {
        return privacy;
    }

    /**
     * @param privacy the privacy to set
     */
    public void setPrivacy(Boolean privacy) {
        this.privacy = privacy;
    }

    /**
     * @return the outdoor
     */
    public Boolean getOutdoor() {
        return outdoor;
    }

    /**
     * @param outdoor the outdoor to set
     */
    public void setOutdoor(Boolean outdoor) {
        this.outdoor = outdoor;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return the starting
     */
    public Date getStarting() {
        return starting;
    }

    /**
     * @param starting the starting to set
     */
    public void setStarting(Date starting) {
        this.starting = starting;
    }

    /**
     * @return the ending
     */
    public Date getEnding() {
        return ending;
    }

    /**
     * @param ending the ending to set
     */
    public void setEnding(Date ending) {
        this.ending = ending;
    }

}
